<!-- 合并开票组件 -->
<template>
  <el-dialog
    :title="dialogTitle"
    :visible.sync="visible"
    width="600px"
    append-to-body
  >
    <el-form ref="form" :model="formData" label-width="140px">
      <el-form-item label="抬头" prop="unitName">
        <el-input v-model="formData.unitName" placeholder="请输入单位名称" />
      </el-form-item>
      <el-form-item label="单位统一信用代码" prop="unitCreditCode">
        <el-input v-model="formData.unitCreditCode" placeholder="请输入单位统一信用代码" />
      </el-form-item>
      <el-form-item label="发票发送手机号" prop="invoicePhone">
        <el-input v-model="formData.invoicePhone" placeholder="请输入发票发送手机号" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="handleCancel">取 消</el-button>
      <el-button type="primary" @click="handleSubmit">提 交</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "MergeInvoiceDialog",
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    formData: {
      type: Object,
      default: () => ({
        unitName: '',
        unitCreditCode: '',
        invoicePhone: ''
      })
    }
  },
  computed: {
    dialogTitle() {
      return '合并开票';
    }
  },
  methods: {
    handleCancel() {
      this.$emit('close');
    },
    handleSubmit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.$emit('submit', this.formData);
        }
      });
    }
  }
};
</script>

<style scoped>
.dialog-footer {
  text-align: right;
}
</style>